// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <pollux/python/type/PyType.h>

namespace py = pybind11;

PYBIND11_MODULE(type, m) {
  using namespace kumo;

  py::class_<pollux::py::PyType>(m, "Type")
      .def("__str__", &pollux::py::PyType::toString)
      .def("__eq__", [](pollux::py::PyType& u, pollux::py::PyType& v) {
        return u.equivalent(v);
      });

  m.def("BIGINT", &pollux::py::PyType::createBigint);
  m.def("INTEGER", &pollux::py::PyType::createInteger);
  m.def("SMALLINT", &pollux::py::PyType::createSmallint);
  m.def("TINYINT", &pollux::py::PyType::createTinyint);
  m.def("BOOLEAN", &pollux::py::PyType::createBoolean);

  m.def("REAL", &pollux::py::PyType::createReal);
  m.def("DOUBLE", &pollux::py::PyType::createDouble);

  m.def("VARCHAR", &pollux::py::PyType::createVarchar);
  m.def("VARBINARY", &pollux::py::PyType::createVarbinary);

  m.def("DATE", &pollux::py::PyType::createDate);

  m.def("ARRAY", &pollux::py::PyType::createArrayType, py::arg("elements_type"));
  m.def(
      "MAP",
      &pollux::py::PyType::createMapType,
      py::arg("key_type"),
      py::arg("value_type"));
  m.def(
      "ROW",
      &pollux::py::PyType::createRowType,
      py::arg("names") = std::vector<std::string>{},
      py::arg("types") = std::vector<pollux::py::PyType>{});
}
